set more off
clear
use "ANES2008PA (raw).dta"


**********Dependent Variable: Vote Choice****************
gen vote = . 
replace vote = 1 if W11A6 == 13
replace vote = 0 if W11A6 == 18
label def vot 1 "McCain" 0 "Obama"
label var vote "Vote Choice"
label values vote vot

**********Main Ind. Variable: Policy Attitude, Importance, Proximity****************
  
*******Same-Sex Marriage***
****own attitutde & attitude strength**.
*question asks about an amendment banning same sex marriage; favor is thus conservative and coded high*
*wave 1*
gen samesex1  = . 
replace samesex1 = 1 if W1P1 == 2 & W1P_O_2 == 1
replace samesex1 = 2 if W1P1 == 2 & W1P_O_2 == 2
replace samesex1 = 3 if W1P1 == 2 & W1P_O_2 == 3
replace samesex1 = 4 if W1P1 == 3
replace samesex1 = 5 if W1P1 == 1 & W1P_F_2 == 3
replace samesex1 = 6 if W1P1 == 1 & W1P_F_2 == 2
replace samesex1 = 7 if W1P1 == 1 & W1P_F_2 == 1
label var samesex1 "Support/Opposition to Same Sex Marriage Ban (W1)"
label def same 7 "Great Deal Support" 6 "Moderate Support" 5 "Little Support" 4 "Neither" 3 "Little Oppose" 2 "Moderate Oppose" 1 "Great Deal of Opposition"
label values samesex1 same

gen samesex1ext = . 
replace samesex1ext = 1 if samesex1 == 4
replace samesex1ext = 2 if samesex1 == 3
replace samesex1ext = 2 if samesex1 == 5
replace samesex1ext = 3 if samesex1 == 2
replace samesex1ext = 3 if samesex1 == 6
replace samesex1ext = 4 if samesex1 == 7
replace samesex1ext = 4 if samesex1 == 1
label var samesex1ext "Extremity of Same Sex Attitude (W1)"
label def extreme 1 "Neither" 2 "A Little" 3 "Moderately" 4 "A Great Deal"
label values samesex1ext extreme

gen samesex1imp = .
replace samesex1imp = 1 if W1P3 == 5
replace samesex1imp = 2 if W1P3 == 4
replace samesex1imp = 3 if W1P3 == 3
replace samesex1imp = 4 if W1P3 == 2
replace samesex1imp = 5 if W1P3 == 1
label var samesex1imp "Importance of Sam Sex Attitude (W1)"
label def importa 1 "Not at all" 2 "Slightly" 3 "Moderately" 4 "Very" 5 "Extremely"
label values samesex1imp importa


*wave 10
gen samesex10 = . 
replace samesex10 = 1 if W10P1 == 2 & W10P2_OP == 1
replace samesex10 = 2 if W10P1 == 2 & W10P2_OP == 2
replace samesex10 = 3 if W10P1 == 2 & W10P2_OP == 3
replace samesex10 = 4 if W10P1 == 3
replace samesex10 = 5 if W10P1 == 1 & W10P2_FA == 3
replace samesex10 = 6 if W10P1 == 1 & W10P2_FA == 2
replace samesex10 = 7 if W10P1 == 1 & W10P2_FA == 1
label var samesex10 "Support/Opposition to Same Sex Marriage Ban (W10)"
label values samesex10 same

gen samesex10ext = . 
replace samesex10ext = 1 if samesex10 == 4
replace samesex10ext = 2 if samesex10 == 3
replace samesex10ext = 2 if samesex10 == 5
replace samesex10ext = 3 if samesex10 == 2
replace samesex10ext = 3 if samesex10 == 6
replace samesex10ext = 4 if samesex10 == 7
replace samesex10ext = 4 if samesex10 == 1
label var samesex10ext "Extremity of Same Sex Attitude (W10)"
label values samesex10ext extreme

gen samesex10imp = .
replace samesex10imp = 1 if W10P3 == 5
replace samesex10imp = 2 if W10P3 == 4
replace samesex10imp = 3 if W10P3 == 3
replace samesex10imp = 4 if W10P3 == 2
replace samesex10imp = 5 if W10P3 == 1
label var samesex10imp "Importance of Sam Sex Attitude (W10)"
label values samesex10imp importa

*****candidate placements**
*Wave 6*
gen samesex6obama = . 
replace samesex6obama = 7 if W9PB1 == 1 & W9PB2_FA == 1
replace samesex6obama = 6 if W9PB1 == 1 & W9PB2_FA == 2
replace samesex6obama = 5 if W9PB1 == 1 & W9PB2_FA == 3
replace samesex6obama = 4 if W9PB1 == 3
replace samesex6obama = 3 if W9PB1 == 2 & W9PB2_OP == 3
replace samesex6obama = 2 if W9PB1 == 2 & W9PB2_OP == 2
replace samesex6obama = 1 if W9PB1 == 2 & W9PB2_OP == 1


gen samesex6mccain = . 
replace samesex6mccain = 7 if W9PJ1 == 1 & W9PJ2_FA == 1
replace samesex6mccain = 6 if W9PJ1 == 1 & W9PJ2_FA == 2
replace samesex6mccain = 5 if W9PJ1 == 1 & W9PJ2_FA == 3
replace samesex6mccain = 4 if W9PJ1 == 3
replace samesex6mccain = 3 if W9PJ1 == 2 & W9PJ2_OP == 3
replace samesex6mccain = 2 if W9PJ1 == 2 & W9PJ2_OP == 2
replace samesex6mccain = 1 if W9PJ1 == 2 & W9PJ2_OP == 1

tab samesex6mccain
tab samesex6mccain W9PJ1
tab samesex6mccain W9PJ2_FA
tab samesex6mccain W9PJ2_OP

*Wave 9*

gen samesex9obama = . 
replace samesex9obama = 7 if W9PB1 == 1 & W9PB2_FA == 1
replace samesex9obama = 6 if W9PB1 == 1 & W9PB2_FA == 2
replace samesex9obama = 5 if W9PB1 == 1 & W9PB2_FA == 3
replace samesex9obama = 4 if W9PB1 == 3
replace samesex9obama = 3 if W9PB1 == 2 & W9PB2_OP == 3
replace samesex9obama = 2 if W9PB1 == 2 & W9PB2_OP == 2
replace samesex9obama = 1 if W9PB1 == 2 & W9PB2_OP == 1

tab samesex9obama W9PB1
tab samesex9obama W9PB2_FA
tab samesex9obama W9PB2_OP

gen samesex9mccain = . 
replace samesex9mccain = 7 if W9PJ1 == 1 & W9PJ2_FA == 1
replace samesex9mccain = 6 if W9PJ1 == 1 & W9PJ2_FA == 2
replace samesex9mccain = 5 if W9PJ1 == 1 & W9PJ2_FA == 3
replace samesex9mccain = 4 if W9PJ1 == 3
replace samesex9mccain = 3 if W9PJ1 == 2 & W9PJ2_OP == 3
replace samesex9mccain = 2 if W9PJ1 == 2 & W9PJ2_OP == 2
replace samesex9mccain = 1 if W9PJ1 == 2 & W9PJ2_OP == 1

tab samesex9mccain W9PJ1

*Wave 10&*
gen samesex10obama = . 
replace samesex10obama = 7 if W10PB1 == 1 & W10PB2_F == 1
replace samesex10obama = 6 if W10PB1 == 1 & W10PB2_F == 2
replace samesex10obama = 5 if W10PB1 == 1 & W10PB2_F == 3
replace samesex10obama = 4 if W10PB1 == 3
replace samesex10obama = 3 if W10PB1 == 2 & W10PB2_O == 3
replace samesex10obama = 2 if W10PB1 == 2 & W10PB2_O == 2
replace samesex10obama = 1 if W10PB1 == 2 & W10PB2_O == 1

gen samesex10mccain = . 
replace samesex10mccain = 7 if W10PJ1 == 1 & W10PJ2_F == 1
replace samesex10mccain = 6 if W10PJ1 == 1 & W10PJ2_F == 2
replace samesex10mccain = 5 if W10PJ1 == 1 & W10PJ2_F == 3
replace samesex10mccain = 4 if W10PJ1 == 3
replace samesex10mccain = 3 if W10PJ1 == 2 & W10PJ2_O == 3
replace samesex10mccain = 2 if W10PJ1 == 2 & W10PJ2_O == 2
replace samesex10mccain = 1 if W10PJ1 == 2 & W10PJ2_O == 1



pwcorr samesex*obama, sig
pwcorr samesex*mccain, sig

**proximity***
*ci  samesex6obama samesex6mccain samesex9obama  samesex9mccain samesex10obama samesex10mccain

gen samesex16prox = abs(samesex1 - 3.399637) - abs(samesex1 - 3.787295)
gen samesex19prox = abs(samesex1 - 3.275325) - abs(samesex1 - 4.280193)
gen samesex110prox = abs(samesex1 - 3.258895) - abs(samesex1 - 4.238204)
gen samesex10prox = abs(samesex10 - 3.258895) - abs(samesex10 - 4.238204)

 

**standardization***
*standardized*


foreach var in samesex1ext samesex1imp samesex10ext samesex10imp samesex16prox samesex19prox samesex110prox samesex10prox  {
		qui sum `var'
		gen `var'01 = (`var' - `r(min)') / (`r(max)'-`r(min)')
	}
	
	label var samesex10prox01 "Same Sex Marriage: Prox"
	label var samesex10imp01 "Same Sex Marriage:Imp"

***************Taxes: < 200,000***

****own placement & attitude strength*
*coded so that opposition to taxes is high (presumed to be the conservative position in general)
*self-placement only available from wave 1*
gen poortaxes1 = .
replace poortaxes1 = 1 if W1P7 ==  1 & W1P_F_8 == 1
replace poortaxes1 = 2 if W1P7 ==  1 & W1P_F_8 == 2
replace poortaxes1 = 3 if W1P7 ==  1 & W1P_F_8 == 3
replace poortaxes1 = 4 if W1P7 ==  3
replace poortaxes1 = 5 if W1P7 ==  2 & W1P_O_8 == 3
replace poortaxes1 = 6 if W1P7 ==  2 & W1P_O_8 == 2
replace poortaxes1 = 7 if W1P7 ==  2 & W1P_O_8 == 1
label var poortaxes1 "Favor/Oppose Raising Taxes on <$200 (W1)"

gen poortaxes1ext = .
replace poortaxes1ext = 1 if poortaxes1 == 4
replace poortaxes1ext = 2 if poortaxes1 == 5
replace poortaxes1ext = 2 if poortaxes1 == 3
replace poortaxes1ext = 3 if poortaxes1 == 2
replace poortaxes1ext = 3 if poortaxes1 == 6
replace poortaxes1ext = 4 if poortaxes1 == 1
replace poortaxes1ext = 4 if poortaxes1 == 7
label var poortaxes1ext "Extremity of Taxes on <$200 Attitude (W1)"
label values poortaxes1ext extreme

gen poortaxes1imp = .
replace poortaxes1imp = 1 if W1P9 == 5
replace poortaxes1imp = 2 if W1P9 == 4
replace poortaxes1imp = 3 if W1P9 == 3
replace poortaxes1imp = 4 if W1P9 == 2
replace poortaxes1imp = 5 if W1P9 == 1
label values poortaxes1imp importa
label var poortaxes1imp "Importance of <$200 Attitude (W1)"

***candidate placements****
*Wave 6*
gen poortaxes6obama = . 
replace poortaxes6obama = 1 if W9PB7 == 1  & W9PB8_FA   == 1
replace poortaxes6obama = 2 if W9PB7 == 1  & W9PB8_FA   == 2
replace poortaxes6obama = 3 if W9PB7 == 1  & W9PB8_FA   == 3
replace poortaxes6obama = 4 if W9PB7 == 3  
replace poortaxes6obama = 5 if W9PB7 == 2  & W9PB8_OP   == 3
replace poortaxes6obama = 6 if W9PB7 == 2  & W9PB8_OP   == 2
replace poortaxes6obama = 7 if W9PB7 == 2  & W9PB8_OP   == 1

gen poortaxes6mccain = . 
replace poortaxes6mccain = 1 if W9PJ7 == 1  & W9PJ8_FA   == 1
replace poortaxes6mccain = 2 if W9PJ7 == 1  & W9PJ8_FA   == 2
replace poortaxes6mccain = 3 if W9PJ7 == 1  & W9PJ8_FA   == 3
replace poortaxes6mccain = 4 if W9PJ7 == 3  
replace poortaxes6mccain = 5 if W9PJ7 == 2  & W9PJ8_OP   == 3
replace poortaxes6mccain = 6 if W9PJ7 == 2  & W9PJ8_OP   == 2
replace poortaxes6mccain = 7 if W9PJ7 == 2  & W9PJ8_OP   == 1

*Wave 9*
gen poortaxes9obama = . 
replace poortaxes9obama = 1 if W9PB7 == 1  & W9PB8_FA   == 1
replace poortaxes9obama = 2 if W9PB7 == 1  & W9PB8_FA   == 2
replace poortaxes9obama = 3 if W9PB7 == 1  & W9PB8_FA   == 3
replace poortaxes9obama = 4 if W9PB7 == 3  
replace poortaxes9obama = 5 if W9PB7 == 2  & W9PB8_OP   == 3
replace poortaxes9obama = 6 if W9PB7 == 2  & W9PB8_OP   == 2
replace poortaxes9obama = 7 if W9PB7 == 2  & W9PB8_OP   == 1

gen poortaxes9mccain = . 
replace poortaxes9mccain = 1 if W9PJ7 == 1  & W9PJ8_FA   == 1
replace poortaxes9mccain = 2 if W9PJ7 == 1  & W9PJ8_FA   == 2
replace poortaxes9mccain = 3 if W9PJ7 == 1  & W9PJ8_FA   == 3
replace poortaxes9mccain = 4 if W9PJ7 == 3  
replace poortaxes9mccain = 5 if W9PJ7 == 2  & W9PJ8_OP   == 3
replace poortaxes9mccain = 6 if W9PJ7 == 2  & W9PJ8_OP   == 2
replace poortaxes9mccain = 7 if W9PJ7 == 2  & W9PJ8_OP   == 1


***proximity***
*ci  poortaxes6obama poortaxes6mccain poortaxes9obama poortaxes9mccain

gen poortaxes16prox = abs(poortaxes1 - 4.51317) - abs(poortaxes1 - 4.850927)
gen poortaxes19prox = abs(poortaxes1 - 4.676558) - abs(poortaxes1 - 4.973949)


***standardization***

foreach var in poortaxes1ext poortaxes1imp poortaxes16prox poortaxes19prox   {
		qui sum `var'
		gen `var'01 = (`var' - `r(min)') / (`r(max)'-`r(min)')
	}


	
	
	
************Taxes > 200,000***
***own attitude and attitude strength****
*opposition is conservative position, so coded high*
*wave 1*
gen richtaxes1 = . 
replace richtaxes1 = 7 if W1P4 == 2 & W1P_O_5 == 1 
replace richtaxes1 = 6 if W1P4 == 2 & W1P_O_5 == 2
replace richtaxes1 = 5 if W1P4 == 2 & W1P_O_5== 3
replace richtaxes1 = 4 if W1P4 == 3
replace richtaxes1 = 3 if W1P4 == 1 & W1P_F_5 == 3
replace richtaxes1 = 2 if W1P4 == 1 & W1P_F_5 == 2
replace richtaxes1 = 1 if W1P4 == 1 & W1P_F_5 == 1
label var richtaxes1 "Supp./Opp. Raising Taxes > $200 (W1)"

gen richtaxes1ext = .
replace richtaxes1ext = 1 if richtaxes1 == 4
replace richtaxes1ext = 2 if richtaxes1 == 3
replace richtaxes1ext = 2 if richtaxes1 == 5
replace richtaxes1ext = 3 if richtaxes1 == 2
replace richtaxes1ext = 3 if richtaxes1 == 6
replace richtaxes1ext = 4 if richtaxes1 == 1
replace richtaxes1ext = 4 if richtaxes1 == 7
label var richtaxes1ext "Extremity of Supp./Opp. Taxes (W1)"

gen richtaxes1imp = .
replace richtaxes1imp = 1 if W1P6 == 5
replace richtaxes1imp = 2 if W1P6 == 4
replace richtaxes1imp = 3 if W1P6 == 3
replace richtaxes1imp = 4 if W1P6 == 2
replace richtaxes1imp = 5 if W1P6 == 1
label var richtaxes1imp "Importance of Taxes > $200 (W1)"

*wave 10*
gen richtaxes10 = . 
replace richtaxes10 = 1 if W10P4 == 1 & W10P5_FA == 1 
replace richtaxes10 = 2 if W10P4 == 1 & W10P5_FA == 2
replace richtaxes10 = 3 if W10P4 == 1 & W10P5_FA == 3
replace richtaxes10 = 4 if W10P4 == 3
replace richtaxes10 = 5 if W10P4 == 2 & W10P5_OP == 3
replace richtaxes10 = 6 if W10P4 == 2 & W10P5_OP == 2
replace richtaxes10 = 7 if W10P4 == 2 & W10P5_OP == 1
label var richtaxes10 "Supp./Opp. Raising Taxes > $200 (W10)"

gen richtaxes10ext = .
replace richtaxes10ext = 1 if richtaxes10 == 4
replace richtaxes10ext = 2 if richtaxes10 == 3
replace richtaxes10ext = 2 if richtaxes10 == 5
replace richtaxes10ext = 3 if richtaxes10 == 2
replace richtaxes10ext = 3 if richtaxes10 == 6
replace richtaxes10ext = 4 if richtaxes10 == 1
replace richtaxes10ext = 4 if richtaxes10 == 7
label var richtaxes10ext "Extremity of Supp./Opp. Taxes (W10)"


gen richtaxes10imp = .
replace richtaxes10imp = 1 if W10P6 == 5
replace richtaxes10imp = 2 if W10P6 == 4
replace richtaxes10imp = 3 if W10P6 == 3
replace richtaxes10imp = 4 if W10P6 == 2
replace richtaxes10imp = 5 if W10P6 == 1
label var richtaxes10imp "Importance of Taxes > $200 (W10)"
label values richtaxes10imp importa

***candidate placements***
*W9*
gen richtaxes6obama = . 
replace richtaxes6obama = 7 if W9PB4 == 2 & W9PB5_OP == 1
replace richtaxes6obama = 6 if W9PB4 == 2 & W9PB5_OP == 2
replace richtaxes6obama = 5 if W9PB4 == 2 & W9PB5_OP == 3
replace richtaxes6obama = 4 if W9PB4 == 3
replace richtaxes6obama = 3 if W9PB4 == 1 & W9PB5_FA == 3
replace richtaxes6obama = 2 if W9PB4 == 1 & W9PB5_FA == 2
replace richtaxes6obama = 1 if W9PB4 == 1 & W9PB5_FA == 1


gen richtaxes6mccain = .
replace richtaxes6mccain = 7 if W9PJ4 == 2 & W9PJ5_OP == 1
replace richtaxes6mccain = 6 if W9PJ4 == 2 & W9PJ5_OP == 2
replace richtaxes6mccain = 5 if W9PJ4 == 2 & W9PJ5_OP == 3
replace richtaxes6mccain = 4 if W9PJ4 == 3
replace richtaxes6mccain = 3 if W9PJ4 == 1 & W9PJ5_FA == 3
replace richtaxes6mccain = 2 if W9PJ4 == 1 & W9PJ5_FA == 2
replace richtaxes6mccain = 1 if W9PJ4 == 1 & W9PJ5_FA == 1

tab richtaxes6mccain
tab richtaxes6obama


*w9*
gen richtaxes9obama = . 
replace richtaxes9obama = 7 if W9PB4 == 2 & W9PB5_OP == 1
replace richtaxes9obama = 6 if W9PB4 == 2 & W9PB5_OP == 2
replace richtaxes9obama = 5 if W9PB4 == 2 & W9PB5_OP == 3
replace richtaxes9obama = 4 if W9PB4 == 3
replace richtaxes9obama = 3 if W9PB4 == 1 & W9PB5_FA == 3
replace richtaxes9obama = 2 if W9PB4 == 1 & W9PB5_FA == 2
replace richtaxes9obama = 1 if W9PB4 == 1 & W9PB5_FA == 1


gen richtaxes9mccain = .
replace richtaxes9mccain = 7 if W9PJ4 == 2 & W9PJ5_OP == 1
replace richtaxes9mccain = 6 if W9PJ4 == 2 & W9PJ5_OP == 2
replace richtaxes9mccain = 5 if W9PJ4 == 2 & W9PJ5_OP == 3
replace richtaxes9mccain = 4 if W9PJ4 == 3
replace richtaxes9mccain = 3 if W9PJ4 == 1 & W9PJ5_FA == 3
replace richtaxes9mccain = 2 if W9PJ4 == 1 & W9PJ5_FA == 2
replace richtaxes9mccain = 1 if W9PJ4 == 1 & W9PJ5_FA == 1

tab richtaxes9mccain
tab richtaxes9obama

*w10*
gen richtaxes10obama = . 
replace richtaxes10obama = 7 if W10PB4 == 2 & W10PB5_O == 1
replace richtaxes10obama = 6 if W10PB4 == 2 & W10PB5_O == 2
replace richtaxes10obama = 5 if W10PB4 == 2 & W10PB5_O == 3
replace richtaxes10obama = 4 if W10PB4 == 3
replace richtaxes10obama = 3 if W10PB4 == 1 & W10PB5_F == 3
replace richtaxes10obama = 2 if W10PB4 == 1 & W10PB5_F == 2
replace richtaxes10obama = 1 if W10PB4 == 1 & W10PB5_F == 1

gen richtaxes10mccain = .
replace richtaxes10mccain = 7 if W10PJ4 == 2 & W10PJ5_O == 1
replace richtaxes10mccain = 6 if W10PJ4 == 2 & W10PJ5_O == 2
replace richtaxes10mccain = 5 if W10PJ4 == 2 & W10PJ5_O == 3
replace richtaxes10mccain = 4 if W10PJ4 == 3
replace richtaxes10mccain = 3 if W10PJ4 == 1 & W10PJ5_F == 3
replace richtaxes10mccain = 2 if W10PJ4 == 1 & W10PJ5_F == 2
replace richtaxes10mccain = 1 if W10PJ4 == 1 & W10PJ5_F == 1


***proximity***
*ci  richtaxes6obama richtaxes6mccain richtaxes9obama richtaxes9mccain  richtaxes10obama richtaxes10mccain

gen richtaxes16prox = abs(richtaxes1 - 2.326679) - abs(richtaxes1 - 4.9301)
gen richtaxes19prox = abs(richtaxes1 - 2.037862) - abs(richtaxes1 - 5.224991)
gen richtaxes110prox = abs(richtaxes1 - 1.936984) - abs(richtaxes1 - 5.643293)
gen richtaxes10prox = abs(richtaxes10 - 1.936984) - abs(richtaxes10 - 5.643293)

**standardization**


foreach var in richtaxes1ext richtaxes1imp richtaxes10ext richtaxes10imp richtaxes16prox richtaxes19prox richtaxes110prox richtaxes10prox  {
		qui sum `var'
		gen `var'01 = (`var' - `r(min)') / (`r(max)'-`r(min)')
	}

		label var richtaxes10imp01 "Tax the Rich:Prox"
		label var richtaxes10prox01 "Tax the Rich:Imp"
	
	
*************Low Income Senior Drugs***
**own position and attitude strength**
*oppose = high*
*W1*
gen drugs1 = . 
replace drugs1 = 7 if W1P10 == 2 & W1P_O_11 == 1
replace drugs1 = 6 if W1P10 == 2 & W1P_O_11 == 2
replace drugs1 = 5 if W1P10 == 2 & W1P_O_11 == 3
replace drugs1 = 4 if W1P10 == 3
replace drugs1 = 3 if W1P10 == 1 & W1P_F_11 == 3
replace drugs1 = 2 if W1P10 == 1 & W1P_F_11 == 2
replace drugs1 = 1 if W1P10 == 1 & W1P_F_11 == 1
label var drugs1 "Favor/Oppose Paying for Low Income Senior Drugs (W1)"

gen drugs1ext = .
replace drugs1ext = 1 if drugs1 == 4
replace drugs1ext = 2 if drugs1 == 5
replace drugs1ext = 2 if drugs1 == 3
replace drugs1ext = 3 if drugs1 == 2
replace drugs1ext = 3 if drugs1 == 6
replace drugs1ext = 4 if drugs1 == 1
replace drugs1ext = 4 if drugs1 == 7
label var drugs1ext "Extremity of Senior Drugs Attitude (W1)"

gen drugs1imp = .
replace drugs1imp = 1 if W1P12 == 5
replace drugs1imp = 2 if W1P12 == 4
replace drugs1imp = 3 if W1P12 == 3
replace drugs1imp = 4 if W1P12 == 2
replace drugs1imp = 5 if W1P12 == 1
label var drugs1imp "Importance of Senior Drugs Attitude (W1)"

*W10*
gen drugs10 = .
replace drugs10 = 7 if W10P10 == 2 & W10P11_O == 1
replace drugs10 = 6 if W10P10 == 2 & W10P11_O == 2
replace drugs10 = 5 if W10P10 == 2 & W10P11_O == 3
replace drugs10 = 4 if W10P10 == 3
replace drugs10 = 3 if W10P10 == 1 & W10P11_F == 3
replace drugs10 = 2 if W10P10 == 1 & W10P11_F == 2
replace drugs10 = 1 if W10P10 == 1 & W10P11_F == 1
label var drugs10 "Favor/Oppose Paying for Low Income Senior Drugs (W10)"

gen drugs10ext = .
replace drugs10ext = 1 if drugs10 == 4
replace drugs10ext = 2 if drugs10 == 5
replace drugs10ext = 2 if drugs10 == 3
replace drugs10ext = 3 if drugs10 == 6
replace drugs10ext = 3 if drugs10 == 2
replace drugs10ext = 4 if drugs10 == 1
replace drugs10ext = 4 if drugs10 == 7
label var drugs10ext "Extremity of Senior Drugs Attitude (W10)"
label values drugs10ext extreme

gen drugs10imp = .
replace drugs10imp = 1 if W10P12 == 5
replace drugs10imp = 2 if W10P12 == 4
replace drugs10imp = 3 if W10P12 == 3
replace drugs10imp = 4 if W10P12 == 2
replace drugs10imp = 5 if W10P12 == 1
label var drugs10imp "Importance of Senior Drugs Attitude (W10)"
label values drugs10imp importa

****Candidate Placeements****
*W9*
gen drugs6obama = .
replace drugs6obama = 7 if W9PB10 == 2 & W9PB11_O == 1
replace drugs6obama = 6 if W9PB10 == 2 & W9PB11_O == 2
replace drugs6obama = 5 if W9PB10 == 2 & W9PB11_O == 3
replace drugs6obama = 4 if W9PB10 == 3
replace drugs6obama = 3 if W9PB10 == 1 & W9PB11_F == 3
replace drugs6obama = 2 if W9PB10 == 1 & W9PB11_F == 2
replace drugs6obama = 1 if W9PB10 == 1 & W9PB11_F == 1

gen drugs6mccain = .
replace drugs6mccain = 7 if W9PJ10 == 2 & W9PJ11_O == 1
replace drugs6mccain = 6 if W9PJ10 == 2 & W9PJ11_O == 2
replace drugs6mccain = 5 if W9PJ10 == 2 & W9PJ11_O == 3
replace drugs6mccain = 4 if W9PJ10 == 3
replace drugs6mccain = 3 if W9PJ10 == 1 & W9PJ11_F == 3
replace drugs6mccain = 2 if W9PJ10 == 1 & W9PJ11_F == 2
replace drugs6mccain = 1 if W9PJ10 == 1 & W9PJ11_F == 1


*W9*

gen drugs9obama = .
replace drugs9obama = 7 if W9PB10 == 2 & W9PB11_O == 1
replace drugs9obama = 6 if W9PB10 == 2 & W9PB11_O == 2
replace drugs9obama = 5 if W9PB10 == 2 & W9PB11_O == 3
replace drugs9obama = 4 if W9PB10 == 3
replace drugs9obama = 3 if W9PB10 == 1 & W9PB11_F == 3
replace drugs9obama = 2 if W9PB10 == 1 & W9PB11_F == 2
replace drugs9obama = 1 if W9PB10 == 1 & W9PB11_F == 1

gen drugs9mccain = .
replace drugs9mccain = 7 if W9PJ10 == 2 & W9PJ11_O == 1
replace drugs9mccain = 6 if W9PJ10 == 2 & W9PJ11_O == 2
replace drugs9mccain = 5 if W9PJ10 == 2 & W9PJ11_O == 3
replace drugs9mccain = 4 if W9PJ10 == 3
replace drugs9mccain = 3 if W9PJ10 == 1 & W9PJ11_F == 3
replace drugs9mccain = 2 if W9PJ10 == 1 & W9PJ11_F == 2
replace drugs9mccain = 1 if W9PJ10 == 1 & W9PJ11_F == 1


*W10*
gen drugs10obama = .
replace drugs10obama = 7 if W10PB10 == 2 & W10PB1_1 == 1
replace drugs10obama = 6 if W10PB10 == 2 & W10PB1_1 == 2
replace drugs10obama = 5 if W10PB10 == 2 & W10PB1_1 == 3
replace drugs10obama = 4 if W10PB10 == 3
replace drugs10obama = 3 if W10PB10 == 1 & W10PB11_ == 3
replace drugs10obama = 2 if W10PB10 == 1 & W10PB11_ == 2
replace drugs10obama = 1 if W10PB10 == 1 & W10PB11_ == 1

gen drugs10mccain = .
replace drugs10mccain = 7 if W10PJ10 == 2 & W10PJ1_1 == 1
replace drugs10mccain = 6 if W10PJ10 == 2 & W10PJ1_1 == 2
replace drugs10mccain = 5 if W10PJ10 == 2 & W10PJ1_1 == 3
replace drugs10mccain = 4 if W10PJ10 == 3
replace drugs10mccain = 3 if W10PJ10 == 1 & W10PJ11_ == 3
replace drugs10mccain = 2 if W10PJ10 == 1 & W10PJ11_ == 2
replace drugs10mccain = 1 if W10PJ10 == 1 & W10PJ11_ == 1

****Proximity***
*ci  drugs6obama drugs6mccain drugs9obama drugs9mccain drugs10obama drugs10mccain

gen drugs16prox = abs(drugs1 - 2.626364) - abs(drugs1 - 4.521026)
gen drugs19prox = abs(drugs1 - 2.464193) - abs(drugs1 - 4.483079)
gen drugs110prox = abs(drugs1 - 2.216642) - abs(drugs1 - 4.706687)
gen drugs10prox = abs(drugs10 - 2.216642) - abs(drugs10 - 4.706687)

***standardization***

foreach var in drugs1ext drugs1imp drugs10ext drugs10imp drugs16prox drugs19prox drugs110prox drugs10prox  {
		qui sum `var'
		gen `var'01 = (`var' - `r(min)') / (`r(max)'-`r(min)')
	}

	label var drugs10prox01 "Senior Drugs:Prox"
	label var drugs10imp01 "Senior Drugs:Imp"


*********Medical Care***
***own attitude, strength***
*oppose = high*
*w1
gen medic1 = .
replace medic1 = 7 if W1P13 == 2 & W1P_O_14 == 1
replace medic1 = 6 if W1P13 == 2 & W1P_O_14 == 2
replace medic1 = 5 if W1P13 == 2 & W1P_O_14 == 3
replace medic1 = 4 if W1P13 == 3
replace medic1 = 3 if W1P13 == 1 & W1P_F_14 == 3
replace medic1 = 2 if W1P13 == 1 & W1P_F_14 == 2
replace medic1 = 1 if W1P13 == 1 & W1P_F_14 == 1
label var medic1 "Pay for All Nec. Medical Care (W1)"

gen medic1ext = . 
replace medic1ext = 1 if medic1 == 4
replace medic1ext = 2 if medic1 == 3
replace medic1ext = 2 if medic1 == 5
replace medic1ext = 3 if medic1 == 6
replace medic1ext = 3 if medic1 == 2
replace medic1ext = 4 if medic1 == 1
replace medic1ext = 4 if medic1 == 7
label var medic1ext "Extremity of Medical Care Attitude (W1)"

gen medic1imp = .
replace medic1imp = 1 if W1P15 == 5
replace medic1imp = 2 if W1P15 == 4
replace medic1imp = 3 if W1P15 == 3
replace medic1imp = 4 if W1P15 == 2
replace medic1imp = 5 if W1P15 == 1
label var medic1imp "Importance of Medical Care Attitude (W1)"
label values medic1imp importa
*w10
gen medic10 = . 
replace medic10 = 7 if W10P13 == 2 & W10P14_O == 1
replace medic10 = 6 if W10P13 == 2 & W10P14_O == 2
replace medic10 = 5 if W10P13 == 2 & W10P14_O == 3
replace medic10 = 4 if W10P13 == 3
replace medic10 = 3 if W10P13 == 1 & W10P14_F == 3
replace medic10 = 2 if W10P13 == 1 & W10P14_F == 2
replace medic10 = 1 if W10P13 == 1 & W10P14_F == 1
label var medic10 "Pay for All Nec. Medical Care (W10)"

gen medic10ext = .
replace medic10ext = 1 if medic10 == 4
replace medic10ext = 2 if medic10 == 3
replace medic10ext = 2 if medic10 == 5
replace medic10ext = 3 if medic10 == 2
replace medic10ext = 3 if medic10 == 6
replace medic10ext = 4 if medic10 == 1
replace medic10ext = 4 if medic10 == 7
label var medic10ext "Extremity of Medical Care Attitude (W10)"

gen medic10imp = .
replace medic10imp = 1 if W10P15 == 5
replace medic10imp = 2 if W10P15 == 4
replace medic10imp = 3 if W10P15 == 3
replace medic10imp = 4 if W10P15 == 2
replace medic10imp = 5 if W10P15 == 1
label var medic10imp "Importance of Medical Care Attitude (W10)"


****candidate placement
*wave 6

gen medic6obama = .
replace medic6obama = 7 if W9PB13 == 2 & W9PB14_O == 1
replace medic6obama = 6 if W9PB13 == 2 & W9PB14_O == 2
replace medic6obama = 5 if W9PB13 == 2 & W9PB14_O == 3
replace medic6obama = 4 if W9PB13 == 3
replace medic6obama = 3 if W9PB13 == 1 & W9PB14_F == 3
replace medic6obama = 2 if W9PB13 == 1 & W9PB14_F == 2
replace medic6obama = 1 if W9PB13 == 1 & W9PB14_F == 1

gen medic6mccain = .
replace medic6mccain = 7 if W9PJ13 == 2 & W9PJ14_O == 1
replace medic6mccain = 6 if W9PJ13 == 2 & W9PJ14_O == 2
replace medic6mccain = 5 if W9PJ13 == 2 & W9PJ14_O == 3
replace medic6mccain = 4 if W9PJ13 == 3
replace medic6mccain = 3 if W9PJ13 == 1 & W9PJ14_F == 3
replace medic6mccain = 2 if W9PJ13 == 1 & W9PJ14_F == 2
replace medic6mccain = 1 if W9PJ13 == 1 & W9PJ14_F == 1

*wave 9

gen medic9obama = .
replace medic9obama = 7 if W9PB13 == 2 & W9PB14_O == 1
replace medic9obama = 6 if W9PB13 == 2 & W9PB14_O == 2
replace medic9obama = 5 if W9PB13 == 2 & W9PB14_O == 3
replace medic9obama = 4 if W9PB13 == 3
replace medic9obama = 3 if W9PB13 == 1 & W9PB14_F == 3
replace medic9obama = 2 if W9PB13 == 1 & W9PB14_F == 2
replace medic9obama = 1 if W9PB13 == 1 & W9PB14_F == 1

gen medic9mccain = .
replace medic9mccain = 7 if W9PJ13 == 2 & W9PJ14_O == 1
replace medic9mccain = 6 if W9PJ13 == 2 & W9PJ14_O == 2
replace medic9mccain = 5 if W9PJ13 == 2 & W9PJ14_O == 3
replace medic9mccain = 4 if W9PJ13 == 3
replace medic9mccain = 3 if W9PJ13 == 1 & W9PJ14_F == 3
replace medic9mccain = 2 if W9PJ13 == 1 & W9PJ14_F == 2
replace medic9mccain = 1 if W9PJ13 == 1 & W9PJ14_F == 1


*wave 10
gen medic10obama = .
replace medic10obama = 7 if W10PB13 == 2 & W10PB1_2 == 1
replace medic10obama = 6 if W10PB13 == 2 & W10PB1_2 == 2
replace medic10obama = 5 if W10PB13 == 2 & W10PB1_2 == 3
replace medic10obama = 4 if W10PB13 == 3
replace medic10obama = 3 if W10PB13 == 1 & W10PB14_ == 3
replace medic10obama = 2 if W10PB13 == 1 & W10PB14_ == 2
replace medic10obama = 1 if W10PB13 == 1 & W10PB14_ == 1

gen medic10mccain = .
replace medic10mccain = 7 if W10PJ13 == 2 & W10PJ1_2 == 1
replace medic10mccain = 6 if W10PJ13 == 2 & W10PJ1_2 == 2
replace medic10mccain = 5 if W10PJ13 == 2 & W10PJ1_2 == 3
replace medic10mccain = 4 if W10PJ13 == 3
replace medic10mccain = 3 if W10PJ13 == 1 & W10PJ14_ == 3
replace medic10mccain = 2 if W10PJ13 == 1 & W10PJ14_ == 2
replace medic10mccain = 1 if W10PJ13 == 1 & W10PJ14_ == 1


****proximity
*ci  medic6obama medic6mccain medic9obama medic9mccain medic10obama medic10mccain
gen medic16prox = abs(medic1 - 3.22111) - abs(medic1 - 5.293447)
gen medic19prox = abs(medic1 - 3.061944) - abs(medic1 - 5.326515)
gen medic110prox = abs(medic1 - 2.779445) - abs(medic1 - 5.580989)
gen medic10prox =  abs(medic10 - 2.779445) - abs(medic10 - 5.580989)

***standardization

foreach var in medic1ext medic1imp medic10ext medic10imp medic16prox medic19prox medic110prox medic10prox  {
		qui sum `var'
		gen `var'01 = (`var' - `r(min)') / (`r(max)'-`r(min)')
	}
	
	label var medic10prox01 "Universal Health Care:Prox"
	label var medic10imp01 "Universal Health Care:Imp"
	
	

*******Habeas Corpus Right***
**own attitude & strength*
*favor should be high*
*w1
gen habeas1 = .
replace habeas1 = 7 if W1P16 == 1 & W1P_F_17 == 1
replace habeas1 = 5 if W1P16 == 1 & W1P_F_17 == 2
replace habeas1 = 4 if W1P16 == 1 & W1P_F_17 == 3
replace habeas1 = 4 if W1P16 == 3
replace habeas1 = 3 if W1P16 == 2 & W1P_O_17 == 3
replace habeas1 = 2 if W1P16 == 2 & W1P_O_17 == 2
replace habeas1 = 1 if W1P16 == 2 & W1P_O_17 == 1
label var habeas "Suspend Habeas for Terror Suspects (W1)"

gen habeas1ext = .
replace habeas1ext = 1 if habeas1 == 4
replace habeas1ext = 2 if habeas1 == 3
replace habeas1ext = 2 if habeas1 == 5
replace habeas1ext = 3 if habeas1 == 2
replace habeas1ext = 3 if habeas1 == 6
replace habeas1ext = 4 if habeas1 == 1
replace habeas1ext = 4 if habeas1 == 7
label var habeas1ext "Extremity of Habeas Attitude (W1)"

gen habeas1imp = .
replace habeas1imp = 1 if W1P18 == 5
replace habeas1imp = 2 if W1P18 == 4
replace habeas1imp = 3 if W1P18 == 3
replace habeas1imp = 4 if W1P18 == 2
replace habeas1imp = 5 if W1P18 == 1
label var habeas1imp "Importance of Habeas Attitude (W1)"
label values habeas1imp importa


*w10*
gen habeas10 = .
replace habeas10 = 7 if W10P16 == 1 & W10P17_F == 1
replace habeas10 = 6 if W10P16 == 1 & W10P17_F == 2
replace habeas10 = 5 if W10P16 == 1 & W10P17_F == 3
replace habeas10 = 4 if W10P16 == 3
replace habeas10 = 3 if W10P16 == 2 & W10P17_O == 3
replace habeas10 = 2 if W10P16 == 2 & W10P17_O == 2
replace habeas10 = 1 if W10P16 == 2 & W10P17_O == 1
label var habeas10 "Suspend Habeas for Terror Suspects (W10)"

gen habeas10ext = .
replace habeas10ext = 1 if habeas10 == 4
replace habeas10ext = 2 if habeas10 == 3
replace habeas10ext = 2 if habeas10 == 5
replace habeas10ext = 3 if habeas10 == 2
replace habeas10ext = 3 if habeas10 == 6
replace habeas10ext = 4 if habeas10 == 1
replace habeas10ext = 4 if habeas10 == 7
label var habeas10ext "Extremity of Habeas Attitude (W10)"

gen habeas10imp = .
replace habeas10imp = 1 if W10P18 == 5
replace habeas10imp = 2 if W10P18 == 4
replace habeas10imp = 3 if W10P18 == 3
replace habeas10imp = 4 if W10P18 == 2
replace habeas10imp = 5 if W10P18 == 1
label var habeas10imp "Importance of Habeas Attitude (W10)"

*****candidate placements****
*W9
gen habeas6obama = . 
replace habeas6obama = 7 if W9PB16 == 1 & W9PB17_F == 1
replace habeas6obama = 6 if W9PB16 == 1 & W9PB17_F == 2
replace habeas6obama = 5 if W9PB16 == 1 & W9PB17_F == 3
replace habeas6obama = 4 if W9PB16 == 3
replace habeas6obama = 3 if W9PB16 == 2 & W9PB17_O == 3
replace habeas6obama = 2 if W9PB16 == 2 & W9PB17_O == 2
replace habeas6obama = 1 if W9PB16 == 2 & W9PB17_O == 1

gen habeas6mccain = . 
replace habeas6mccain = 7 if W9PJ16 == 1 & W9PJ17_F == 1
replace habeas6mccain = 6 if W9PJ16 == 1 & W9PJ17_F == 2
replace habeas6mccain = 5 if W9PJ16 == 1 & W9PJ17_F == 3
replace habeas6mccain = 4 if W9PJ16 == 3
replace habeas6mccain = 3 if W9PJ16 == 2 & W9PJ17_O == 3
replace habeas6mccain = 2 if W9PJ16 == 2 & W9PJ17_O == 2
replace habeas6mccain = 1 if W9PJ16 == 2 & W9PJ17_O == 1

*w9
gen habeas9obama = . 
replace habeas9obama = 7 if W9PB16 == 1 & W9PB17_F == 1
replace habeas9obama = 6 if W9PB16 == 1 & W9PB17_F == 2
replace habeas9obama = 5 if W9PB16 == 1 & W9PB17_F == 3
replace habeas9obama = 4 if W9PB16 == 3
replace habeas9obama = 3 if W9PB16 == 2 & W9PB17_O == 3
replace habeas9obama = 2 if W9PB16 == 2 & W9PB17_O == 2
replace habeas9obama = 1 if W9PB16 == 2 & W9PB17_O == 1

gen habeas9mccain = . 
replace habeas9mccain = 7 if W9PJ16 == 1 & W9PJ17_F == 1
replace habeas9mccain = 6 if W9PJ16 == 1 & W9PJ17_F == 2
replace habeas9mccain = 5 if W9PJ16 == 1 & W9PJ17_F == 3
replace habeas9mccain = 4 if W9PJ16 == 3
replace habeas9mccain = 3 if W9PJ16 == 2 & W9PJ17_O == 3
replace habeas9mccain = 2 if W9PJ16 == 2 & W9PJ17_O == 2
replace habeas9mccain = 1 if W9PJ16 == 2 & W9PJ17_O == 1


*W10
gen habeas10obama = . 
replace habeas10obama = 7 if W10PB16 == 1 & W10PB17_ == 1
replace habeas10obama = 6 if W10PB16 == 1 & W10PB17_ == 2
replace habeas10obama = 5 if W10PB16 == 1 & W10PB17_ == 3
replace habeas10obama = 4 if W10PB16 == 3
replace habeas10obama = 3 if W10PB16 == 2 & W10PB1_3 == 3
replace habeas10obama = 2 if W10PB16 == 2 & W10PB1_3 == 2
replace habeas10obama = 1 if W10PB16 == 2 & W10PB1_3 == 1

gen habeas10mccain = . 
replace habeas10mccain = 7 if W10PJ16 == 1 & W10PJ17_ == 1
replace habeas10mccain = 6 if W10PJ16 == 1 & W10PJ17_ == 2
replace habeas10mccain = 5 if W10PJ16 == 1 & W10PJ17_ == 3
replace habeas10mccain = 4 if W10PJ16 == 3
replace habeas10mccain = 3 if W10PJ16 == 2 & W10PJ1_3 == 3
replace habeas10mccain = 2 if W10PJ16 == 2 & W10PJ1_3 == 2
replace habeas10mccain = 1 if W10PJ16 == 2 & W10PJ1_3 == 1

***proximity****
*ci  habeas6obama habeas6mccain habeas9obama habeas9mccain habeas10obama habeas10mccain
gen habeas16prox = abs(habeas1 - 2.44505) - abs(habeas1 - 4.60913)
gen habeas19prox = abs(habeas1 - 2.340267) - abs(habeas1 - 4.629188)
gen habeas110prox = abs(habeas1 - 2.460366) - abs(habeas1 - 4.441469)
gen habeas10prox = abs(habeas10 - 2.460366) - abs(habeas10 - 4.441469)

*standardization*
foreach var in habeas1ext habeas1imp habeas10ext habeas10imp habeas16prox habeas19prox habeas110prox habeas10prox  {
		qui sum `var'
		gen `var'01 = (`var' - `r(min)') / (`r(max)'-`r(min)')
	}
	
	label var habeas10prox01 "Habeas Corpus:Prox"
	label var habeas10imp01 "Habeas Corpus:Imp"

*********Court Orders for Wiretaps***
***own attitude and strength*
gen phone1 = .
replace phone1 = 7 if W1P19 == 2 & W1P_O_20 == 1
replace phone1 = 6 if W1P19 == 2 & W1P_O_20 == 2
replace phone1 = 5 if W1P19 == 2 & W1P_O_20 == 3
replace phone1 = 4 if W1P19 == 3
replace phone1 = 3 if W1P19 == 1 & W1P_F_20 == 3
replace phone1 = 2 if W1P19 == 1 & W1P_F_20 == 2
replace phone1 = 1 if W1P19 == 1 & W1P_F_20 == 1
label var phone1 "Court Order to Phone Tap Terror Suspects (W1)"

gen phone1ext = .
replace phone1ext = 1 if phone1 == 4
replace phone1ext = 2 if phone1 == 3
replace phone1ext = 2 if phone1 == 5
replace phone1ext = 3 if phone1 == 2
replace phone1ext = 3 if phone1 == 6
replace phone1ext = 4 if phone1 == 1
replace phone1ext = 4 if phone1 == 7
label var phone1ext "Extremity of Phone Tap Attitude (W1)"
label values phone1ext extreme

gen phone1imp = .
replace phone1imp = 1 if W1P21 == 5
replace phone1imp = 2 if W1P21 == 4
replace phone1imp = 3 if W1P21 == 3
replace phone1imp = 4 if W1P21 == 2
replace phone1imp = 5 if W1P21 == 1
label var phone1imp "Importance of Phone Tap Attitude (W1)"
label values phone1imp importa

*w10*
gen phone10 = .
replace phone10 = 7 if W10P19 == 2 & W10P20_O == 1
replace phone10 = 6 if W10P19 == 2 & W10P20_O == 2
replace phone10 = 5 if W10P19 == 2 & W10P20_O == 3
replace phone10 = 4 if W10P19 == 3
replace phone10 = 3 if W10P19 == 1 & W10P20_F == 3
replace phone10 = 2 if W10P19 == 1 & W10P20_F == 2
replace phone10 = 1 if W10P19 == 1 & W10P20_F == 1
label var phone10 "Court Order to Phone Tap Terror Suspects (W10)"

gen phone10ext = .
replace phone10ext = 1 if phone10 == 4
replace phone10ext = 2 if phone10 == 5
replace phone10ext = 2 if phone10 == 3
replace phone10ext = 3 if phone10 == 2
replace phone10ext = 3 if phone10 == 6
replace phone10ext = 4 if phone10 == 1
replace phone10ext = 4 if phone10 == 7
label var phone10ext "Extremity of Phone Tap Attitude (W10)"
label values phone10ext extreme

gen phone10imp = .
replace phone10imp = 1 if W10P21 == 5
replace phone10imp = 2 if W10P21 == 4
replace phone10imp = 3 if W10P21 == 3
replace phone10imp = 4 if W10P21 == 2
replace phone10imp = 5 if W10P21 == 1
label var phone10imp "Importance of Phone Tap Attitude (W10)"
label values phone10imp importa

***candidate placements***
*W9
gen phone6obama = .
replace phone6obama = 7 if W9PB19 == 2 & W9PB20_O == 1
replace phone6obama = 6 if W9PB19 == 2 & W9PB20_O == 2
replace phone6obama = 5 if W9PB19 == 2 & W9PB20_O == 3
replace phone6obama = 4 if W9PB19 == 3
replace phone6obama = 3 if W9PB19 == 1 & W9PB20_F == 3
replace phone6obama = 2 if W9PB19 == 1 & W9PB20_F == 2
replace phone6obama = 1 if W9PB19 == 1 & W9PB20_F == 1


gen phone6mccain = .
replace phone6mccain = 7 if W9PJ19 == 2 & W9PJ20_O == 1
replace phone6mccain = 6 if W9PJ19 == 2 & W9PJ20_O == 2
replace phone6mccain = 5 if W9PJ19 == 2 & W9PJ20_O == 3
replace phone6mccain = 4 if W9PJ19 == 3
replace phone6mccain = 3 if W9PJ19 == 1 & W9PJ20_F == 3
replace phone6mccain = 2 if W9PJ19 == 1 & W9PJ20_F == 2
replace phone6mccain = 1 if W9PJ19 == 1 & W9PJ20_F == 1


*W9
gen phone9obama = .
replace phone9obama = 7 if W9PB19 == 2 & W9PB20_O == 1
replace phone9obama = 6 if W9PB19 == 2 & W9PB20_O == 2
replace phone9obama = 5 if W9PB19 == 2 & W9PB20_O == 3
replace phone9obama = 4 if W9PB19 == 3
replace phone9obama = 3 if W9PB19 == 1 & W9PB20_F == 3
replace phone9obama = 2 if W9PB19 == 1 & W9PB20_F == 2
replace phone9obama = 1 if W9PB19 == 1 & W9PB20_F == 1


gen phone9mccain = .
replace phone9mccain = 7 if W9PJ19 == 2 & W9PJ20_O == 1
replace phone9mccain = 6 if W9PJ19 == 2 & W9PJ20_O == 2
replace phone9mccain = 5 if W9PJ19 == 2 & W9PJ20_O == 3
replace phone9mccain = 4 if W9PJ19 == 3
replace phone9mccain = 3 if W9PJ19 == 1 & W9PJ20_F == 3
replace phone9mccain = 2 if W9PJ19 == 1 & W9PJ20_F == 2
replace phone9mccain = 1 if W9PJ19 == 1 & W9PJ20_F == 1

*w10
gen phone10obama = .
replace phone10obama = 7 if W10PB19 == 2 & W10PB2_1 == 1
replace phone10obama = 6 if W10PB19 == 2 & W10PB2_1 == 2
replace phone10obama = 5 if W10PB19 == 2 & W10PB2_1 == 3
replace phone10obama = 4 if W10PB19 == 3
replace phone10obama = 3 if W10PB19 == 1 & W10PB20_ == 3
replace phone10obama = 2 if W10PB19 == 1 & W10PB20_ == 2
replace phone10obama = 1 if W10PB19 == 1 & W10PB20_ == 1

gen phone10mccain = .
replace phone10mccain = 7 if W10PJ19 == 2 & W10PJ2_1 == 1
replace phone10mccain = 6 if W10PJ19 == 2 & W10PJ2_1 == 2
replace phone10mccain = 5 if W10PJ19 == 2 & W10PJ2_1 == 3
replace phone10mccain = 4 if W10PJ19 == 3
replace phone10mccain = 3 if W10PJ19 == 1 & W10PJ20_ == 3
replace phone10mccain = 2 if W10PJ19 == 1 & W10PJ20_ == 2
replace phone10mccain = 1 if W10PJ19 == 1 & W10PJ20_ == 1

**proximity*
*ci   phone6obama phone6mccain phone9obama phone9mccain phone10obama phone10mccain
gen phone16prox = abs(phone1 - 2.822142) - abs(phone1 - 4.217857)
gen phone19prox = abs(phone1 - 2.700743) - abs(phone1 - 4.327252)
gen phone110prox = abs(phone1 - 2.809774) - abs(phone1 - 4.259571)
gen phone10prox = abs(phone10 - 2.809774) - abs(phone10 - 4.259571)


**standardiation**
foreach var in phone1ext phone1imp phone10ext phone10imp phone16prox phone19prox phone110prox phone10prox  {
		qui sum `var'
		gen `var'01 = (`var' - `r(min)') / (`r(max)'-`r(min)')
	}

	label var phone10prox01 "Wiretaps:Prox"
	label var phone10imp01 "Wiretaps:imp"
	
	
*******Work Stay for Illegal Immigrants***
***own attitude, attitude strength**
*w1*
gen illeg1 = .
replace illeg1 = 7 if W1P22 == 2 & W1P_O_23 == 1
replace illeg1 = 6 if W1P22 == 2 & W1P_O_23 == 2
replace illeg1 = 5 if W1P22 == 2 & W1P_O_23 == 3
replace illeg1 = 4 if W1P22 == 3
replace illeg1 = 3 if W1P22 == 1 & W1P_F_23 == 3
replace illeg1 = 2 if W1P22 == 1 & W1P_F_23 == 2
replace illeg1 = 1 if W1P22 == 1 & W1P_F_23 == 1
label var illeg1 "Allow Ill. Immigrants to Work for 3 Years (W1)"

gen illeg1ext = . 
replace illeg1ext = 1 if illeg1 == 4
replace illeg1ext = 2 if illeg1 == 5
replace illeg1ext = 2 if illeg1 == 3
replace illeg1ext = 3 if illeg1 == 6
replace illeg1ext = 3 if illeg1 == 2
replace illeg1ext = 4 if illeg1 == 1
replace illeg1ext = 4 if illeg1 == 7

gen illeg1imp = .
replace illeg1imp = 1 if W1P24 == 5
replace illeg1imp = 2 if W1P24 == 4
replace illeg1imp = 3 if W1P24 == 3
replace illeg1imp = 4 if W1P24 == 2
replace illeg1imp = 5 if W1P24 == 1
label var illeg1imp "Importance of Ill. Immigrants Working Attitude (W1)"
label values illeg1imp importa

*W10
gen illeg10 = .
replace illeg10 = 7 if W10P22 == 2 & W10P23_O == 1
replace illeg10 = 6 if W10P22 == 2 & W10P23_O == 2
replace illeg10 = 5 if W10P22 == 2 & W10P23_O == 3
replace illeg10 = 4 if W10P22 == 3
replace illeg10 = 3 if W10P22 == 1 & W10P23_F == 3
replace illeg10 = 2 if W10P22 == 1 & W10P23_F == 2
replace illeg10 = 1 if W10P22 == 1 & W10P23_F == 1
label var illeg10 "Allow Ill. Immigrants to Work for 3 Years (W10)"

gen illeg10ext = .
replace illeg10ext = 1 if illeg10 == 4
replace illeg10ext = 2 if illeg10 == 3
replace illeg10ext = 2 if illeg10 == 5
replace illeg10ext = 3 if illeg10 == 2
replace illeg10ext = 3 if illeg10 == 6
replace illeg10ext = 4 if illeg10 == 1
replace illeg10ext = 4 if illeg10 == 7
label var illeg10ext "Extremity of Ill. Immigrants Working Attitude (W10)"

gen illeg10imp = .
replace illeg10imp = 1 if W10P24 == 5
replace illeg10imp = 2 if W10P24 == 4
replace illeg10imp = 3 if W10P24 == 3
replace illeg10imp = 4 if W10P24 == 2
replace illeg10imp = 5 if W10P24 == 1
label var illeg10imp "Importance of Ill. Immigrants Working Attitude (W10)"
label values illeg10imp importa

****Candidate Placements***
*W6
gen illeg6obama = . 
replace illeg6obama = 7 if W6PB22 == 2 & W6PB23_O == 1
replace illeg6obama = 6 if W6PB22 == 2 & W6PB23_O  == 2
replace illeg6obama = 5 if W6PB22 == 2 & W6PB23_O  == 3
replace illeg6obama = 4 if W6PB22 == 3
replace illeg6obama = 3 if W6PB22 == 1 & W6PB23_F == 3
replace illeg6obama = 2 if W6PB22 == 1 & W6PB23_F == 2
replace illeg6obama = 1 if W6PB22 == 1 & W6PB23_F == 1

gen illeg6mccain = .
replace illeg6mccain = 7 if W6PJ22 == 2 & W6PJ23_O  == 1
replace illeg6mccain = 6 if W6PJ22 == 2 & W6PJ23_O  == 2
replace illeg6mccain = 5 if W6PJ22 == 2 & W6PJ23_O  == 3
replace illeg6mccain = 4 if W6PJ22 == 3
replace illeg6mccain = 3 if W6PJ22 == 1 & W6PJ23_F == 3
replace illeg6mccain = 2 if W6PJ22 == 1 & W6PJ23_F == 2
replace illeg6mccain = 1 if W6PJ22 == 1 & W6PJ23_F == 1

*W9
gen illeg9obama = . 
replace illeg9obama = 7 if W9PB22 == 2 & W9PB23_O == 1
replace illeg9obama = 6 if W9PB22 == 2 & W9PB23_O  == 2
replace illeg9obama = 5 if W9PB22 == 2 & W9PB23_O  == 3
replace illeg9obama = 4 if W9PB22 == 3
replace illeg9obama = 3 if W9PB22 == 1 & W9PB23_F == 3
replace illeg9obama = 2 if W9PB22 == 1 & W9PB23_F == 2
replace illeg9obama = 1 if W9PB22 == 1 & W9PB23_F == 1

gen illeg9mccain = .
replace illeg9mccain = 7 if W9PJ22 == 2 & W9PJ23_O  == 1
replace illeg9mccain = 6 if W9PJ22 == 2 & W9PJ23_O  == 2
replace illeg9mccain = 5 if W9PJ22 == 2 & W9PJ23_O  == 3
replace illeg9mccain = 4 if W9PJ22 == 3
replace illeg9mccain = 3 if W9PJ22 == 1 & W9PJ23_F == 3
replace illeg9mccain = 2 if W9PJ22 == 1 & W9PJ23_F == 2
replace illeg9mccain = 1 if W9PJ22 == 1 & W9PJ23_F == 1

*w10
gen illeg10obama = . 
replace illeg10obama = 7 if W10PB22 == 2 & W10PB2_2 == 1
replace illeg10obama = 6 if W10PB22 == 2 & W10PB2_2 == 2
replace illeg10obama = 5 if W10PB22 == 2 & W10PB2_2 == 3
replace illeg10obama = 4 if W10PB22 == 3
replace illeg10obama = 3 if W10PB22 == 1 & W10PB23_ == 3
replace illeg10obama = 2 if W10PB22 == 1 & W10PB23_ == 2
replace illeg10obama = 1 if W10PB22 == 1 & W10PB23_ == 1

gen illeg10mccain = .
replace illeg10mccain = 7 if W10PJ22 == 2 & W10PJ2_2 == 1
replace illeg10mccain = 6 if W10PJ22 == 2 & W10PJ2_2 == 2
replace illeg10mccain = 5 if W10PJ22 == 2 & W10PJ2_2 == 3
replace illeg10mccain = 4 if W10PJ22 == 3
replace illeg10mccain = 3 if W10PJ22 == 1 & W10PJ23_ == 3
replace illeg10mccain = 2 if W10PJ22 == 1 & W10PJ23_ == 2
replace illeg10mccain = 1 if W10PJ22 == 1 & W10PJ23_ == 1

***proximity*
*ci  illeg6obama illeg6mccain illeg9obama illeg9mccain illeg10obama illeg10mccain
gen illeg16prox =  abs(illeg1 - 3.624886) - abs(illeg1 - 4.024964)
gen illeg19prox =   abs(illeg1 - 3.587775) - abs(illeg1 - 4.0242)
gen illeg110prox =    abs(illeg1 - 3.278071) - abs(illeg1 - 4.092226)
gen illeg10prox = abs(illeg10 - 3.278071) - abs(illeg10 - 4.092226)

***standardization***
foreach var in illeg1ext illeg1imp illeg10ext illeg10imp illeg16prox illeg19prox illeg110prox illeg10prox  {
		qui sum `var'
		gen `var'01 = (`var' - `r(min)') / (`r(max)'-`r(min)')
	}

	label var illeg10imp01 "Illeg Imm Work: Imp"
	label var illeg10prox01 "Illeg Imm Work: Prox"
	
*(**********Path to Citizenship***
**own attitude and strength**
*w1
gen path1 = . 
replace path1 = 7 if W1P25 == 2 & W1P_O_26 == 1
replace path1 = 6 if W1P25 == 2 & W1P_O_26 == 2
replace path1 = 5 if W1P25 == 2 & W1P_O_26 == 3
replace path1 = 4 if W1P25 == 3
replace path1 = 3 if W1P25 == 1 & W1P_F_26 == 3
replace path1 = 2 if W1P25 == 1 & W1P_F_26 == 2
replace path1 = 1 if W1P25 == 1 & W1P_F_26 == 1
label var path1 "Pathway to Citizenship (W1)"

gen path1ext = .
replace path1ext = 1 if path1 == 4
replace path1ext = 2 if path1 == 3
replace path1ext = 2 if path1 == 5
replace path1ext = 3 if path1 == 2
replace path1ext = 3 if path1 == 6
replace path1ext = 4 if path1 == 1
replace path1ext = 4 if path1 == 7
label var path1ext "Extremity of Pathway to Citizenship Attitude (W1)"

gen path1imp = .
replace path1imp = 1 if W1P27 == 5
replace path1imp = 2 if W1P27 == 4
replace path1imp = 3 if W1P27 == 3
replace path1imp = 4 if W1P27 == 2
replace path1imp = 5 if W1P27 == 1
label var path1imp "Importance of Pathway to Citizenship Att. (W1)"

*w10
gen path10 = .
replace path10 = 7 if W10P25 == 2 & W10P26_O == 1
replace path10 = 6 if W10P25 == 2 & W10P26_O == 2
replace path10 = 5 if W10P25 == 2 & W10P26_O == 3
replace path10 = 4 if W10P25 == 3
replace path10 = 3 if W10P25 == 1 & W10P26_F == 3
replace path10 = 2 if W10P25 == 1 & W10P26_F == 2
replace path10 = 1 if W10P25 == 1 & W10P26_F == 1
label var path10 "Pathway to Citizenship (W10)"

gen path10ext = .
replace path10ext = 1 if path10 == 4
replace path10ext = 2 if path10 == 3
replace path10ext = 2 if path10 == 5
replace path10ext = 3 if path10 == 2
replace path10ext = 3 if path10 == 6
replace path10ext = 4 if path10 == 1
replace path10ext = 4 if path10 == 7
label var path10ext "Extremity of Pathway to Citizenship Attitude (W10)"

gen path10imp = .
replace path10imp = 1 if W10P27 == 5
replace path10imp = 2 if W10P27 == 4
replace path10imp = 3 if W10P27 == 3
replace path10imp = 4 if W10P27 == 2
replace path10imp = 5 if W10P27 == 1
label var path10imp "Importance of Pathway to Citizenship Attitude (W10)"
label values path10imp importa

***candidate placements****
*w6

gen path6obama = .
replace path6obama = 7 if W6PB25 == 2 & W6PB26_O == 1
replace path6obama = 6 if W6PB25 == 2 & W6PB26_O == 2
replace path6obama = 5 if W6PB25 == 2 & W6PB26_O == 3
replace path6obama = 4 if W6PB25 == 3
replace path6obama = 3 if W6PB25 == 1 & W6PB26_F == 3
replace path6obama = 2 if W6PB25 == 1 & W6PB26_F == 2
replace path6obama = 1 if W6PB25 == 1 & W6PB26_F == 1

gen path6mccain = .
replace path6mccain = 7 if W6PJ25 == 2 & W6PJ26_O == 1
replace path6mccain = 6 if W6PJ25 == 2 & W6PJ26_O == 2
replace path6mccain = 5 if W6PJ25 == 2 & W6PJ26_O == 3
replace path6mccain = 4 if W6PJ25 == 3
replace path6mccain = 3 if W6PJ25 == 1 & W6PJ26_F == 3
replace path6mccain = 2 if W6PJ25 == 1 & W6PJ26_F == 2
replace path6mccain = 1 if W6PJ25 == 1 & W6PJ26_F == 1



*w9
gen path9obama = .
replace path9obama = 7 if W9PB25 == 2 & W9PB26_O == 1
replace path9obama = 6 if W9PB25 == 2 & W9PB26_O == 2
replace path9obama = 5 if W9PB25 == 2 & W9PB26_O == 3
replace path9obama = 4 if W9PB25 == 3
replace path9obama = 3 if W9PB25 == 1 & W9PB26_F == 3
replace path9obama = 2 if W9PB25 == 1 & W9PB26_F == 2
replace path9obama = 1 if W9PB25 == 1 & W9PB26_F == 1

gen path9mccain = .
replace path9mccain = 7 if W9PJ25 == 2 & W9PJ26_O == 1
replace path9mccain = 6 if W9PJ25 == 2 & W9PJ26_O == 2
replace path9mccain = 5 if W9PJ25 == 2 & W9PJ26_O == 3
replace path9mccain = 4 if W9PJ25 == 3
replace path9mccain = 3 if W9PJ25 == 1 & W9PJ26_F == 3
replace path9mccain = 2 if W9PJ25 == 1 & W9PJ26_F == 2
replace path9mccain = 1 if W9PJ25 == 1 & W9PJ26_F == 1


*w10
gen path10obama = .
replace path10obama = 7 if W10PB25 == 2 & W10PB2_3 == 1
replace path10obama = 6 if W10PB25 == 2 & W10PB2_3 == 2
replace path10obama = 5 if W10PB25 == 2 & W10PB2_3 == 3
replace path10obama = 4 if W10PB25 == 3
replace path10obama = 3 if W10PB25 == 1 & W10PB26_ == 3
replace path10obama = 2 if W10PB25 == 1 & W10PB26_ == 2
replace path10obama = 1 if W10PB25 == 1 & W10PB26_ == 1

gen path10mccain = .
replace path10mccain = 7 if W10PJ25 == 2 & W10PJ2_3 == 1
replace path10mccain = 6 if W10PJ25 == 2 & W10PJ2_3 == 2
replace path10mccain = 5 if W10PJ25 == 2 & W10PJ2_3 == 3
replace path10mccain = 4 if W10PJ25 == 3
replace path10mccain = 3 if W10PJ25 == 1 & W10PJ26_ == 3
replace path10mccain = 2 if W10PJ25 == 1 & W10PJ26_ == 2
replace path10mccain = 1 if W10PJ25 == 1 & W10PJ26_ == 1

***proximity*
*ci path6obama path6mccain path9obama path9mccain path10obama path10mccain

gen path16prox = abs(path1 - 2.740909) - abs(path1 - 3.907989)
gen path19prox = abs(path1 - 2.683897) - abs(path1 - 3.896462)
gen path110prox = abs(path1 - 2.726451) - abs(path1 - 3.896712)
gen path10prox = abs(path10 - 2.726451) - abs(path10 - 3.896712)


***standardization***
foreach var in path1ext path1imp path10ext path10imp path16prox path19prox path110prox path10prox  {
		qui sum `var'
		gen `var'01 = (`var' - `r(min)') / (`r(max)'-`r(min)')
	}
	
	
	label var path10imp01 "Path to Citizenship:Imp"
	label var path10prox01 "Path to Citizenship:Prox"

****Deadline for Withdrawal****

*W6*
gen withdraw6 = .
replace withdraw6 = 7 if W6M4 == 2 & W6M5B == 1
replace withdraw6 = 6 if W6M4 == 2 & W6M5B == 2
replace withdraw6 = 5 if W6M4 == 2 & W6M5B == 3
replace withdraw6 = 4 if W6M4 == 3
replace withdraw6 = 3 if W6M4 == 1 & W6M5A == 3 
replace withdraw6 = 2 if W6M4 == 1 & W6M5A == 2
replace withdraw6 = 1 if W6M4 == 1 & W6M5A == 1
label var withdraw6 "Deadline for Troop Withdrawal (W6)"

gen withdraw6ext = .
replace withdraw6ext = 1 if withdraw6 == 4
replace withdraw6ext = 2 if withdraw6 == 3
replace withdraw6ext = 2 if withdraw6 == 5
replace withdraw6ext = 3 if withdraw6 == 2
replace withdraw6ext = 3 if withdraw6 == 6
replace withdraw6ext = 4 if withdraw6 == 1
replace withdraw6ext = 4 if withdraw6 == 7
label var withdraw6ext "Extremity of Deadline Attitude (W6)"
label values withdraw6ext extreme

gen withdraw6imp = .
replace withdraw6imp = 1 if W6M6 == 5 
replace withdraw6imp = 2 if W6M6 == 4
replace withdraw6imp = 3 if W6M6 == 3
replace withdraw6imp = 4 if W6M6 == 2
replace withdraw6imp = 5 if W6M6 == 1
label var withdraw6imp "Importance of Deadline Attitude (W6)"

*W9
gen withdraw9 = .
replace withdraw9 = 7 if W9Q5 == 2 & W9Q6_OPP == 1
replace withdraw9 = 6 if W9Q5 == 2 & W9Q6_OPP == 2
replace withdraw9 = 5 if W9Q5 == 2 & W9Q6_OPP == 3
replace withdraw9 = 4 if W9Q5 == 3
replace withdraw9 = 3 if W9Q5 == 1 & W9Q6_FAV == 3
replace withdraw9 = 2 if W9Q5 == 1 & W9Q6_FAV == 2
replace withdraw9 = 1 if W9Q5 == 1 & W9Q6_FAV == 1
label var withdraw9 "Deadline for Troop Withdrawal (W9)"

gen withdraw9ext = .
replace withdraw9ext = 1 if withdraw9 == 4
replace withdraw9ext = 2 if withdraw9 == 3
replace withdraw9ext = 2 if withdraw9 == 5
replace withdraw9ext = 3 if withdraw9 == 2
replace withdraw9ext = 3 if withdraw9 == 6
replace withdraw9ext = 4 if withdraw9 == 1
replace withdraw9ext = 4 if withdraw9 == 7
label var withdraw9ext "Extremity of Deadline Attitude (W9)"
label values withdraw9ext extreme

gen withdraw9imp = . 
replace withdraw9imp = 1 if W9Q7 == 5
replace withdraw9imp = 2 if W9Q7 == 4
replace withdraw9imp = 3 if W9Q7 == 3
replace withdraw9imp = 4 if W9Q7 == 2
replace withdraw9imp = 5 if W9Q7 == 1
label var withdraw9imp "Importance of Deadline Attitude (W9)"
label values withdraw9imp importa

*W10
gen withdraw10 = .
replace withdraw10 = 7 if W10Q5 == 2 & W10Q6B == 1
replace withdraw10 = 6 if W10Q5 == 2 & W10Q6B == 2
replace withdraw10 = 5 if W10Q5 == 2 & W10Q6B == 3
replace withdraw10 = 4 if W10Q5 == 3
replace withdraw10 = 3 if W10Q5 == 1 & W10Q6A == 3
replace withdraw10 = 2 if W10Q5 == 1 & W10Q6A == 2
replace withdraw10 = 1 if W10Q5 == 1 & W10Q6A == 1
label var withdraw10 "Deadline for Troop Withdrawal (W10)"

gen withdraw10ext = .
replace withdraw10ext = 1 if withdraw10 == 4
replace withdraw10ext = 2 if withdraw10 == 3
replace withdraw10ext = 2 if withdraw10 == 5
replace withdraw10ext = 3 if withdraw10 == 2
replace withdraw10ext = 3 if withdraw10 == 6
replace withdraw10ext = 4 if withdraw10 == 1
replace withdraw10ext = 4 if withdraw10 == 7
label var withdraw10ext "Extremity of Deadline Attitude (W10)"
label values withdraw10ext extreme

gen withdraw10imp = .
replace withdraw10imp = 1 if W10Q7 == 5
replace withdraw10imp = 2 if W10Q7 == 4
replace withdraw10imp = 3 if W10Q7 == 3
replace withdraw10imp = 4 if W10Q7 == 2
replace withdraw10imp = 5 if W10Q7 == 1
label var withdraw10imp "Importance of Deadline Attitude (W10)"
label values withdraw10imp importa

***Candidate Placements***
*W9
gen withdraw9obama = .
replace withdraw9obama = 7 if W9Q10 == 2 & W9Q11_OP == 1
replace withdraw9obama = 6 if W9Q10 == 2 & W9Q11_OP == 2
replace withdraw9obama = 5 if W9Q10 == 2 & W9Q11_OP == 3
replace withdraw9obama = 4 if W9Q10 == 3
replace withdraw9obama = 3 if W9Q10 == 1 & W9Q11_FA == 3
replace withdraw9obama = 2 if W9Q10 == 1 & W9Q11_FA == 2
replace withdraw9obama = 1 if W9Q10 == 1 & W9Q11_FA == 1
label var withdraw9obama "Obama Placement on Troop Deadline (W9)"

gen withdraw9mccain = .
replace withdraw9mccain = 7 if W9Q8 == 2 & W9Q9_OP == 1
replace withdraw9mccain = 6 if W9Q8 == 2 & W9Q9_OP == 2
replace withdraw9mccain = 5 if W9Q8 == 2 & W9Q9_OP == 3
replace withdraw9mccain = 4 if W9Q8 == 3
replace withdraw9mccain = 3 if W9Q8 == 1 & W9Q9_FAV == 3 
replace withdraw9mccain = 2 if W9Q8 == 1 & W9Q9_FAV == 2
replace withdraw9mccain = 1 if W9Q8 == 1 & W9Q9_FAV == 1 
label var withdraw9mccain "McCain Placement on Troop Deadline (W9)"


*W10
gen withdraw10obama = .
replace withdraw10obama = 7 if W10Q10 == 2 & W10Q11B == 1
replace withdraw10obama = 6 if W10Q10 == 2 & W10Q11B == 2
replace withdraw10obama = 5 if W10Q10 == 2 & W10Q11B == 3
replace withdraw10obama = 4 if W10Q10 == 3
replace withdraw10obama = 3 if W10Q10 == 1 & W10Q11A == 3
replace withdraw10obama = 2 if W10Q10 == 1 & W10Q11A == 2
replace withdraw10obama = 1 if W10Q10 == 1 & W10Q11A == 1


gen withdraw10mccain = .
replace withdraw10mccain = 7 if W10Q8 == 2 & W10Q9B == 1
replace withdraw10mccain = 6 if W10Q8 == 2 & W10Q9B == 2
replace withdraw10mccain = 5 if W10Q8 == 2 & W10Q9B == 3
replace withdraw10mccain = 4 if W10Q8 == 3
replace withdraw10mccain = 3 if W10Q8 == 1 & W10Q9A == 3
replace withdraw10mccain = 2 if W10Q8 == 1 & W10Q9A == 2
replace withdraw10mccain = 1 if W10Q8 == 1 & W10Q9A == 1
label var withdraw10mccain "McCain Placement - Troop Deadline (W10)"

****Proximity***
*ci withdraw9obama withdraw9mccain withdraw10obama withdraw10mccain

gen withdraw69prox = abs(withdraw6 - 1.791667) - abs(withdraw6 - 5.641102)
gen withdraw610prox = abs(withdraw6 - 1.668449) - abs(withdraw6 - 6.032492)
gen withdraw9prox = abs(withdraw9 - 1.791667) - abs(withdraw9 - 5.641102)
gen withdraw910prox = abs(withdraw9 - 1.668449) - abs(withdraw9 - 6.032492)
gen withdraw10prox = abs(withdraw10 - 1.668449) - abs(withdraw10 - 6.032492)

*Standardizatino*
foreach var in withdraw6ext withdraw6imp   withdraw9ext withdraw9imp withdraw10ext withdraw10imp ///
			withdraw69prox withdraw610prox withdraw9prox withdraw910prox withdraw10prox  {
		qui sum `var'
		gen `var'01 = (`var' - `r(min)') / (`r(max)'-`r(min)')
	}
	
	label var withdraw10prox01 "Iraq Troop Withdrawal:Prox"
	label var withdraw10imp01 "Iraq Troopo Withdrawal:Imp"

**********Control Variables****************
*PID*
rename DER08W1 pid1
rename DER08W10 pid10
mvdecode pid1 pid10, mv(-7 = . \ -6 =. \ -5 = . \ -4 = . )

summarize pid1
gen pid101 = (pid1 - `r(min)') / (`r(max)'-`r(min)')
label var pid101 "PID"

summarize pid10
gen pid1001 = (pid10 - `r(min)') / (`r(max)'-`r(min)')
label var pid1001 "PID"

*Ideology*
rename DER09W1 ideology1
rename DER09W10 ideology10
mvdecode ideology1 ideology10, mv(-7 = . \ -6 =. \ -5 = . \ -4 = . )

foreach var in ideology1 ideology10  {
		qui sum `var'
		gen `var'01 = (`var' - `r(min)') / (`r(max)'-`r(min)')
	}
	
	recode ideology10 (1=1) (2=1) (3=1) (4=2) (5=3) (6=3) (7=3) , gen(ideol)
	label var ideol "Ideology"
	label def id 1 "Liberal" 2 "Moderate" 3 "Conservative"
	label values ideol id
	
	
	
*Race*
gen race = . 
replace race = 1 if DER23 == 2
replace race = 0 if DER23 == 1
replace race = 1 if DER23 == 3
label var race "Race"
label def rac 1 "Non-White" 0 "White"
label values race rac

gen hispanic = .
replace hispanic = 1 if DER04 == 3
replace hispanic = 0 if DER04 == 1
replace hispanic = 0 if DER04 == 2
replace hispanic = 0 if DER04 == 4
label var hispanic "Hispanic" 
label def his 1 "Hispanic" 0 "Non-Hispanic"
label values hispanic his


*Gender
gen gender = . 
replace gender = 1 if DER01 == 2
replace gender = 0 if DER01 == 1
label var gender "Gender" 
label def gend 1 "Female" 0 "Male"
label values gender gend

*Age
rename DER02 age
summarize age
gen age01 = (age - r(min))/(r(max)-r(min))
label var age01 "Age"


*Education
gen educ = .
replace educ = 1 if DER05 == 1
replace educ = 2 if DER05 == 2
replace educ = 3 if DER05 == 3
replace educ = 4 if DER05 == 4 
replace educ = 4 if DER05 == 5
label var educ "Education"

summarize educ
gen educ01 = (educ - r(min))/(r(max)-r(min))
label var educ01 

*Income*
rename DER06 income
mvdecode income, mv(-6 = . \ -2 = . )
label var income "Income"

summarize income 
gen income01 = (income - r(min))/(r(max)-r(min))
label var income01 income


*Retro Econ Evals*
gen econ = .
replace econ = 1 if W10U1 == 3 & W10U3 == 1
replace econ = 2 if W10U1 == 3 & W10U3 == 2
replace econ = 3 if W10U1 == 2 
replace econ = 4 if W10U1 == 1 & W10U2 == 2
replace econ = 5 if W10U1 == 1 & W10U2 == 1

summarize econ
gen econ01 = (econ - r(min))/(r(max)-r(min))
label var econ01 "Economic Evals"



*Traits: NOT ASKED ON THE PANEL*

